//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    motto: 'Hello World',
    show:false,
    userInfo: {},
    hasUserInfo: false,
    ellipsis:true,
    flag:true,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  changeYL: function () {
    wx.navigateTo({
      url: '/pages/ljbj/ljbj',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  hideModal: function () {
    this.setData({
      showModal: false
    });
  },
  bj(e) {
    wx.navigateTo({
      url: '/pages/ljbj/ljbj',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })

  },
  wd(e) {
    wx.navigateTo({
      url: '/pages/rmwd/rmwd',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })

  },
  ht(e) {
    wx.navigateTo({
      url: '/pages/rrht/rrht',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })

  },
  gl(e) {
    wx.navigateTo({
      url: '/pages/qzgl/qzgl',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })

  },
  ellipsis: function (e) {  
    // var value = !this.data.ellipsis;
    // console.log(e.currentTarget.dataset.id)
    this.setData({
      select:e.currentTarget.dataset.id
    })
    
    this.setData({
       
      flag: !this.data.flag
    }) 
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else if (this.data.canIUse){
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }
    var that=this;
    wx.request({
      url: 'http://192.168.31.172:3000/allnotelist',
     method:"POST",
        
      success: (res) => {
        console.log(res);
        console.log(res.data);
        that.setData({xq:res.data.reverse()})

      },
    })
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },
  onPullDownRefresh: function () {
    // 下面填写需要下拉时的函数 自己定
     var k = this
     wx.showToast({
       title: '刷新中',
       icon: 'loading',
       duration: 1000
     })
     // 下拉刷新 调用onload函数
     k.onLoad()
    // 注意现在需要使用停止函数停止刷新
     wx.stopPullDownRefresh()
   }

})
